<?php
class Orders_model extends Model 
{
	function Orders_model()
	{
		parent::Model();
		$this->_prefix = $this->config->item('FAL_table_prefix');
        $this->_table = $this->_prefix.'ordertable1';
	}

	function get_order_details($type,$limit,$offset)
	{
		$this->db->select('fa_user.id as id,fa_user.user_name as user_name,fa_ordertable1.date as date,fa_ordertable1.id as oid,fa_ordertable1.order_date,fa_ordertable1.status,fa_ordertable1.servicetype');
		$this->db->join('fa_user', 'fa_user.id = fa_ordertable1.userid');
		$this->db->where('servicetype',$type);
		$this->db->limit($limit, $offset);
		$this->db->order_by('fa_user.id','asc');
		return $this->db->get($this->_table);
	}
	// to insert user orders of type plumber , carpenter , elec, mechanic 
    function insertUserOrder($values)
	{
		$this->db->insert($this->_table,$values);
	}
	function ordered_service($userid)
	{
		$query = $this->db->query("select * from fa_ordertable1 where id=".$userid);
		return $query;
	}
	function order_status($status,$id)
	{
		$data = array(
               'status' => $status,
           			 );
		$query = $this->db->update('fa_ordertable1', $data);
		return $query;
	}
	
	function getOrders($type)
	{
		$this->db->where('servicetype', $type); 
		$result = $this->db->get($this->_table);
		return $result;
	}
}
?>